package com.handler;

import com.service.UserService;
import com.service.impl.UserServiceImpl;
import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

@Slf4j
public class UserInvocationHandler implements InvocationHandler {

    private final UserService userService;

    public UserInvocationHandler(UserService userService) {
        this.userService = userService;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        log.debug("被代理之前执行");
        Object result = method.invoke(userService, args);
        log.debug("被代理之后执行");
        return result;
    }
}
